console.error(error);
}
}
}
handleFoodUpdate(payload) {
const prom = new Promise((r, rej) => {
this.clientFoodAPI.updateFood(this.state.food[0].foodId, { ...payload, foodId: this.state.food[0].foodId }).then((res) => {
this.setState({ food: [{ ...res.data }] }, () => {
r();
});
}, (rejected) => {
console.err(rejected.message);
rej();
});
});
return prom;
}
render() {
const composedData = this.state.nutritionData.map((val, index) => {
const { shortForm, dataSrcId } = this.state.allSources.find((source) => source.dataSrcId === val.dataSrcId) || {};
const { nutrDesc, units, nutrNo } = this.state.allNutrients.find((def) => def.nutrNo === val.nutrNo) || {};
return {
meta: {
index,
relatedIds: {
dataId: val.dataId,
dataSrcId: val.dataSrcId,
nutrNo: val.nutrNo,
},
types: {
nutrDesc: {
type: 'picklist', dataSource: 'allNutrients', labelKey: 'nutrDesc', valueKey: 'nutrNo', stateSourceKey: 'nutrNo',
},
addModDate: 'disabled',
nutrVal: 'number',
units: 'disabled',
shortForm: {
type: 'picklist', dataSource: 'allSources', labelKey: 'shortForm', valueKey: 'dataSrcId', stateSourceKey: 'dataSrcId',
},
},
},
addModDate: val.addModDate,
nutrVal: val.nutrVal,
shortForm,
dataSrcId,
nutrDesc,
nutrNo,
units,
};
});
return (
<div>
{this.state.customNutEditDialogOpen &&
<Dialog
key="editDialog"
open={this.state.customNutEditDialogOpen}
onClose={this.handleClose}
aria-labelledby="form-dialog-title"
classes={{ paperScrollPaper: this.props.classes.dialogContent }}
>
<DialogTitle id="form-dialog-title">Edit Nutrition Row</DialogTitle>
<DialogContent className={this.props.classes.dialogContent}>
{Object.entries(this.state.dialogRow).map((item) => {
const { meta } = this.state.dialogRow;